#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
    char a[101], b[101];

    int cas = 0, alen = 0, blen = 0, count = 1, index;
    scanf("%d", &cas);
    getchar();

    while (cas--)
    {
        int c[100000] = {0};
        scanf("%s %s", a, b);
        alen = strlen(a);
        blen = strlen(b);
        getchar();

        //a、b任何一方为零的情况
        if (strcmp(a, "0") == 0 || strcmp(b, "0") == 0)
        {
            printf("Case %d\n", count);
            printf("%s * %s = 0\n", a, b);
            count++;
        }
        else
        {
            //矩阵运算
            for (size_t i = 0; i < alen; i++)
            {
                for (size_t k = 0; k < blen; k++)
                {
                    //矩阵乘法运算公式
                    c[i + k] += (a[alen - i - 1] - '0') * (b[blen - k - 1] - '0');
                    index = i + k;
                    //满10进1
                    while (c[index] >= 10)
                    {
                        c[index + 1] += c[index] / 10;
                        c[index] %= 10;
                        index++;
                    }
                }
            }

            //寻找运算完成的结果下标
            index = 9999;
            alen = index;
            while (c[index] == 0)
            {
                index--;
                alen = index;
            }
            //输出结果
            printf("Case %d:\n", count);
            printf("%s * %s = ", a, b);
            for (index = alen; index >= 0; index--)
            {
                printf("%d", c[index]);
            }
            printf("\n");

            if (cas >= 1)
            {
                printf("\n");
            }
            count++;
        }
    }

    return 0;
}
